# BIN=stdbin/custom-output/benchmark/dhrystone/dhrystone.bin
# BIN=../../sw/kernel/hello/build/hello.bin
BIN=../../sw/kernel/riscv-test/build/rvc.bin
TESTCASE=stdbin/non-output/riscv-tests 
# TESTCASE=stdbin/non-output/cpu-tests

DUMP_TOOL = gtkwave
DUMP_FLAGS= ?
ifeq ($(DUMP_TOOL) , gtkwave)
DUMP_FLAGS = +dump-vcd
endif
ifeq ($(DUMP_TOOL) , verdi)
DUMP_FLAGS = +dump-wave
endif

vcs:
	make -C $(VCS_SIM_HOME)/difftest

run:
	$(VCS_SIM_HOME)/difftest/simv +workload=$(BIN)  

regression:clean-regression
	$(VCS_SIM_HOME)/regression.sh -r $(TESTCASE) | tee  regression.end

dump:
	$(VCS_SIM_HOME)/difftest/simv +workload=$(BIN) $(DUMP_FLAGS)

wave:
	gtkwave simv.vcd

# verdi -2005 \
# 	-guiConf verdi/novas.conf \
# 	-rcFile  verdi/novas.rc   \
# 	-logdir  verdi/log        \
# 	-f difftest.filelist -ssf simv.fsdb & 	

verdi:
# mkdir -p verdi 
# mkdir -p verdi/log
# touch verdi/novas.rc
# touch verdi/novas.conf
	verdi -2005 \
		-guiConf verdi/novas.conf \
		-rcFile  verdi/novas.rc   \
		-logdir  verdi/log        \
		-f difftest.filelist -ssf simv.fsdb & 

all:vcs run 
all_dump:vcs dump 

clean-run:
	@ rm -rf stack.info.*

clean-regression: clean-run
	@ rm -f  regression.end
	@ rm -rf  log

clean:clean-regression
	@make -C $(VCS_SIM_HOME)/difftest clean
	@rm -rf vc_hdrs.h ucli.key  vcdplus.vpd novas_dump.log novas.rc novas.conf *.fsdb *.vcd verdi verdiLog
	@echo "clean ok!!!"

CM=normal update

git:clean
	cd ../..
	git add *
	git commit -m "$(CM)"
	git push